<template>
	<view class="messageBox">
	
		<image src="../../static/images/bg1.jpg" class="bg" mode=""></image>
			
			<view class="align-center justify-center posRelative" style="margin: 75rpx 0 50rpx;">
				<image style="width: 60rpx;height: 60rpx;" class="mr10" src="../../static/images/5.png" mode=""></image>审核中
			</view>
			<view class="bgWhite radius6 posRelative  mlr10 plr16 ptb18">
				<view class="mb5">
					上传签约合同
				</view>
			<view class="align-center flex-wrap justify-start" >
				<view class="mr10 mt5 posRelative" v-for="(i,n) in imgList" :key="n" >
					<image style="width: 180rpx;height: 180rpx;border-radius: 15rpx;"  :src="i" mode=""></image>
					<view @click="del(n)" class="posAbsort" style="right: 10rpx;top: 10rpx">
						<uv-icon name="close-circle"></uv-icon>
					</view>
				</view>
			</view>
			<view v-if="imgList.length<6"  class="plus align-center justify-center" @click="uploadImg">
				<uv-icon color="#B0B0B0" size="25" name="plus"></uv-icon>
			</view>
			</view>
			
		<view class="save_btn" @click="save">
			提交
		</view>	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content:'',
				imgList:[],
				yingye:""
			};
		},
		onLoad(opt) {
			this.$api.getHetong().then(res=>{
				console.log(res)
				if(res.code==1){
					this.imgList=res.data.xianxiahetong.split(',')
				}
				
			})
		},
		
		methods: {
				
				uploadImg() {
					let vm = this
					uni.chooseImage({
						sourceType: ['album'],
						count: 6-this.imgList.length,
						success: function(res) {
							console.log(res)
							res.tempFilePaths.map(item=>{
								vm.$api.uploadImg({
									filePath:item
								}).then(res => {
									vm.imgList.push(res.data.fullurl)
								})
							})
							
						}
					})
				},
				del(n){
					this.imgList.splice(n,1)
				},
				async save() {
					let vm = this
					if(!this.imgList.length)return this.$utils.msg('请上传合同文件')
					uni.showLoading({})
					vm.$api.xianxiahetong({xianxiahetong:this.imgList.join(',')}).then(res => {
						uni.hideLoading()
						if (res.code == 1) {
							vm.$utils.msg(res.msg)
							setTimeout(() => {
								uni.navigateBack()
							}, 800)
							
						} else {
							vm.$utils.msg(res.msg)
						}
					})
				},
			goBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	.messageBox {
		min-height: 100vh;
		background-color: #F5F5F7;
		

		
	}
	.bg{
		width: 100%;
		height: 380rpx;
		position: absolute;
		left: 0;
		top: 0;
	}
	.plus {
		width: 200rpx;
		height: 200rpx;
		background: #F5F5F7;
		border-radius: 15rpx;
	}
	
	.save_btn {
		width: 690rpx;
		position: fixed;
		bottom: 100rpx;
		left: 0;
		right: 0;
		margin: auto;
		height: 90rpx;
		
		
		background: #49806F;
		border-radius: 12rpx;
		font-size: 32rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 90rpx;
	}
</style>